/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ImportWorldsListItem.java
 *
 * Created on Jun 24, 2011, 11:20:11 AM
 */

package net.worlds.component;

/**
 *
 * @author Jacob Morgan
 */
public class ImportWorldsListItem extends javax.swing.JPanel {

    /** Creates new form ImportWorldsListItem */
    public ImportWorldsListItem(String worldName) {
        initComponents();
        nameTextField.setText(worldName);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        enabledCheckbox = new javax.swing.JCheckBox();
        nameTextField = new javax.swing.JTextField();

        enabledCheckbox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                enabledCheckboxActionPerformed(evt);
            }
        });

        nameTextField.setEditable(false);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(enabledCheckbox)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(nameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(enabledCheckbox)
                    .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void enabledCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enabledCheckboxActionPerformed
        if(enabledCheckbox.getSelectedObjects() != null)
            nameTextField.setEditable(true);
        else
            nameTextField.setEditable(false);
    }//GEN-LAST:event_enabledCheckboxActionPerformed

    public boolean shouldImport()
    {
        return enabledCheckbox.getSelectedObjects() != null;
    }

    public String getNewName()
    {
        return nameTextField.getText();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox enabledCheckbox;
    private javax.swing.JTextField nameTextField;
    // End of variables declaration//GEN-END:variables

}
